$(function(){
    url = 'http://ekang.ren/';
    var w_w = $(window).width();
    var h_h = $(window).height();
    $('.appoint-dactor .header-tab .public').width(w_w/3);
    var header_tabpub_w =  $('.appoint-dactor .header-tab .public').width();
    $('.appoint-dactor .header-tab .public p').width(header_tabpub_w-55);
    $('.appoint-dactor .header-tab .bot-con').height(h_h-45);
//    底部挤出空间
    $('.presence').css('margin-bottom','60px')

    $('.groupconsultationh-datail .topmask').click(function(){
        $('.groupconsultationh-datail .payment-layer .con').animate({'bottom':'-290px'},300,function(){
            $('.payment-layer').hide();
        });
    });
//    点击获取验证码
    wait = 60
    $('.recommend-bot .form .code button').click(function(){
        var phone = $ ('.recommend-bot .form .phone input').val();
        consultationinterface.getcode(phone);
    });
//  点击删除图片
//    var up_pic_list = $()
    $(document).on('click','.groupconsultationh-datail .top-form .pictures .append-pic .list',function(){
        $(this).addClass('animate-rotate');
        $(this).children('.del').show();
    });
    $('body').click(function(){
        $('.groupconsultationh-datail .top-form .pictures .append-pic .list').removeClass('animate-rotate');
        $('.groupconsultationh-datail .top-form .pictures .append-pic .list').children('.del').hide();
    });
    $(document).on('click','.groupconsultationh-datail .top-form .pictures .append-pic .list .del',function(){
        $(this).parents('.list').remove();
        var up_pic_list =  $('.groupconsultationh-datail .top-form .pictures .append-pic .list').length;
        if(up_pic_list<5){
            $('.groupconsultationh-datail .top-form .pictures .up-button').show();
        }
    });
    $('.groupconsultationh-datail .medicalrecord-layer .con p').click(function(){
       $('.groupconsultationh-datail .medicalrecord-layer').hide();
    });
//    radio切换
    $('.groupconsultationh-datail .bot-form .accompany .radio').click(function(){
        var money_price = $('.groupconsultationh-datail .bot-form .money .price').html();
        if($(this).hasClass('hover')){
            $(this).find('.slider').animate({'left':'2px'},400,function(){
                $(this).parent().css('background','#999');
            });
            $(this).removeClass('hover');
            $('.groupconsultationh-datail .bot-form .money .price').html(money_price-388);
        }else{
            $(this).find('.slider').animate({'left':'32px'},400,function(){
                $(this).parent().css('background','#00b57d');
            });
            $('.groupconsultationh-datail .bot-form .money .price').html(parseInt(money_price)+388);
            $(this).addClass('hover');
        }
    });
    $('.groupconsultationh-datail .bot-form .car .radio').click(function(){
        var money_price = $('.groupconsultationh-datail .bot-form .money .price').html();
        if($(this).hasClass('hover')){
            $(this).find('.slider').animate({'left':'2px'},400,function(){
                $(this).parent().css('background','#999');
            });
            $(this).removeClass('hover');
            $('.groupconsultationh-datail .bot-form .money .price').html(money_price-150);
        }else{
            $(this).find('.slider').animate({'left':'32px'},400,function(){
                $(this).parent().css('background','#00b57d');
            });
            $(this).addClass('hover');
            $('.groupconsultationh-datail .bot-form .money .price').html(parseInt(money_price)+150);
        }
    });
//    微信支付宝选择
    $('.groupconsultationh-datail .payment-layer .con .pay-mode .public .radio').click(function(){
       $(this).attr('src','images/icon41.png').parent().siblings('.public').children('.radio').attr('src','images/icon40.png');
        $(this).addClass('hover').parent().siblings('.public').children('.radio').removeClass('hover');
    });
//    评论和专家团简介切换
    $('.presence .bot .title>div').click(function(){
        $(this).addClass('click').siblings().removeClass('click');
        var index = $(this).index();
        $('.presence .bot .con>div').eq(index).show().siblings().hide();
    });
//    帮我推荐病历弹层
    $('.groupconsultationh-datail .top-form .medicalrecord').click(function(){
       $('.medicalrecord-layer').show();
    });
    $(document).on('click','.groupconsultationh-datail .medicalrecord-layer',function(){
       $(this).hide();
    });
    $(document).on('click','.groupconsultationh-datail .medicalrecord-layer .con .public',function(){
        var text = $(this).html();
        var case_id = $(this).data('id');
        $('.groupconsultationh-datail .top-form .medicalrecord .p-name').html(text).attr('data-id',case_id);
        $('.groupconsultationh-datail .medicalrecord-layer').hide();
    });
    $(document).on('click','.groupconsultationh-datail .medicalrecord-layer .con .build',function(){
        location.href='personalrecord.html';
    });

//    点击跳转订单详情
    $(document).on('click','.order_stay .order-list .order-detail .expert,.order_stay .order-list .order-detail .amount button',function(){
        var orderId = $(this).data('id');
        location.href = '../hospital_nurse/consultationorder.html?order_id='+orderId
    });
    $(document).on('click','.order_stay .order-list .order-detail .amount .button2',function(){
        var orderId = $(this).data('id');
        location.href='publish-comment.html?order_id='+orderId
    });
});
//    正则验证
obj={
    "phone":/^(((13[0-9]{1})|(14[0-9]{1})|(17[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/,
    "email":/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/,
    "name":/^[\u4e00-\u9fa5]+$/,
    "num":/^[1-9]+[0-9]*]*$/,
    "Idnumber":/^\d{17}[\w\d]$/,
};
function evaluation (e) {
    var orderId = e.data("id");
    var status = e.data("index");
    var doctorId = e.data("doc");
    var show_status = e.data("show_status")
    var content = e.data("content");
    if(status == 1){ //1表示未付款；2表示已付款；3表示已派单；4表示已完成；5表示已关闭;6已退款;7是退款中
        location.href = "../hospital_nurse/nurse_payorder.html?order_id="+orderId+'&show_status='+show_status+'&content='+content;
    }else if(status == 4){
        location.href = "../myCenter/mycenter_orderevaluation.html?doctor_id="+doctorId;
    }else if(status==2){
        location.href = "../myCenter/order_detail.html?orderId="+orderId;
    }
}
function deleteOrder (o,uid,status,page_size,page_index) {
    $.ajax({
        type: 'POST',
        url: url + '/diagnosis/cancel_order',
        data: {         // 需要于客户端同步
            uid : uid,
            order_id : o
        },
        dataType: 'jsonp',
        jsonp: 'callback',
        success: function (result) {
            if (result.ret == 0) {
                console.log(result)
                $('.order_stay .order-list').html('')
                consultationinterface.order_list(uid,status,page_size,page_index);
            } else {
                alert(result.msg);
            }
        }
    });
}
consultationinterface= {
//    弹层
    layer : function (content){
        $('body').append('<div class="elasticlayer animatescale" style=" z-index: 9999999999999; position: fixed; top:0; width: 100%; height:100%; background:rgba(0,0,0,.7) "><div class="elasticlayercon" style=" background: rgba(255,255,255,1); border-radius: 5px; width: 60%;position: absolute; left: 50%; top: 50%; -webkit-transform:translate(-50%, -50%);"><div class="tit" style=" width: 100%; color:#35424b; text-align: center; padding: 5% 0; font-size: 4vw">易康医疗温馨提醒</div><p style=" width: 90%; margin: auto; text-align: center; font-size: 3.5vw; padding: 5% 0 10% 0; ">'+content+'</p><button style=" display: block; background: none; border: none; padding: 5% 0; font-size:4vw; color: #00b57d; width: 100%; border-top: 1px solid #ddd; letter-spacing: 1px;">确定</button></div></div>')
        $(document).on('click','.elasticlayer .elasticlayercon button',function(){
            $('.elasticlayer').remove();
            $('.publicmask').remove();
        });
    },
//    连接跳转
    link : function(url){
        location.href = url;
    },
//    病例列表
    medical_list : function(uid){
        $.ajax({
            type : 'get',
            url : url+'index.php/diagnosis/consultationPresentation',
            dataType : 'jsonp',
            data : {uid:uid},
            success : function(res) {
                console.log(res);
                var data = res.data;
                if(res.ret==0){
                    $.each(data.case_list,function(i,t){
                        $('.groupconsultationh-datail .medicalrecord-layer .con').append('<p data-case_id="'+ t.case_id+'">'+ t.case_name+'</p>');
                    });
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    获取验证码倒计时
    time : function(o){
        if (wait == 0) {
            o.attr("disabled",false);
            o.html ( "获取验证码");
            wait = 60;
        } else {
            o.attr("disabled", true);
            o.html("重新发送(" + wait + ")");
            wait--;
            setTimeout(function() {
                consultationinterface.time(o)
            },1000)
        }
    },
//    获取验证码
    getcode : function(number){
        $.ajax({
            type : 'get',
            url : url+'user/sendCode/grpCode',
            dataType : 'jsonp',
            data : {cell:number},
            success : function(res) {
                console.log(res);
                if(res.ret==0){
                    consultationinterface.time($('.recommend-bot .form .code button'));
                }else{
                    consultationinterface.layer(res.msg);
                }
            }
        });
    },
//    会诊下单  diagnosis/grpConsultatSubmitOrder
    diagnosis : function(uid,case_id,remark,caseData1,caseData2,caseData3,caseData4,caseData5,doctor_id_arr,appointment_time,coupon_id,user_name,mobile,diagnosis_on,car_on,is_rec){
        $.ajax({
            type : 'post',
            url : url+'diagnosis/grpConsultatSubmitOrder',
            dataType : 'json',
            data : {uid:uid,case_id:case_id,remark:remark,caseData1:caseData1,caseData2:caseData2,caseData3:caseData3,caseData4:caseData4,caseData5:caseData5,doctor_id_arr:doctor_id_arr,appointment_time:appointment_time,coupon_id:coupon_id,user_name:user_name,mobile:mobile,diagnosis_on:diagnosis_on,car_on:car_on,is_rec:is_rec},
            success : function(res) {
                if(res.ret==0){
                    console.log(res);
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    推荐会诊下单  diagnosis/grpConsultatSubmitOrder
    diagnosis2 : function(uid,remark,caseData1,caseData2,caseData3,caseData4,caseData5,user_name,mobile,is_rec){
        $.ajax({
            type : 'post',
            url : url+'diagnosis/grpConsultatSubmitOrder',
            dataType : 'json',
            data : {uid:uid,remark:remark,caseData1:caseData1,caseData2:caseData2,caseData3:caseData3,caseData4:caseData4,caseData5:caseData5,user_name:user_name,mobile:mobile,is_rec:is_rec},
            success : function(res) {
                if(res.ret==0){
                    console.log(res);
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    获取省市
    getCity : function(){
        $.ajax({
            type : 'get',
            url : url+'location/getAreaList/',
            dataType : 'jsonp',
            data : {city_code:110100},
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(res);
                    $.each(data,function(i,t){
                       $('.appoint-dactor .header-tab .bot-con .region-list').append('<p class="list-item " data-code="'+ t.code+'" data-id="'+ t.id+'">'+ t.name+'</p>')
                    });
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    医院列表
    hospital_list : function(city_code){
        $.ajax({
            type : 'get',
            url : url+'hospital/getAll',
            dataType : 'jsonp',
            data : {city_code:city_code},
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(res);
                    $('.appoint-dactor .header-tab .bot-con .hospital-list').append('<p data-id="">全部</p>')
                    $.each(data,function(i,t){
                        $('.appoint-dactor .header-tab .bot-con .hospital-list').append('<p data-id="'+ t.id+'">'+ t.name+'</p>')
                    });

                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    对应分数
    fraction : function(score){
        if(score==1){
            return '非常不满意'
        }else if(score==2){
            return '不满意'
        }else if(score==3){
            return '一般'
        }else if(score==4){
            return '满意'
        }else if(score==5){
            return '非常满意'
        }
    },
//    评论列表
    comment_list : function(grp_id){
        $.ajax({
            type : 'get',
            url : url+'review/group_review_list',
            dataType : 'jsonp',
            data : {page_index:1,page_size:5,grp_id:grp_id},
            success : function(res) {
                var data = res.data.review_list;
                if(res.ret==0){
                    console.log(res);
                    $.each(data,function(i,t){
                        $('.presence .bot .con .con-right .comment').append('<div class="con"><div class="left-head" style=" background: url('+ t.avatar_file+') center; background-size: cover;"></div><div class="user-infor"><p class="name">'+ t.name+'<b>'+ t.c_on+'</b></p><div class="fraction"><div class="div-left">疗效：<b>'+consultationinterface.fraction(t.effect)+'</b></div><div class="div-right">态度：<b>'+consultationinterface.fraction(t.attitude)+'</b></div></div><p class="text">'+ t.review_content+'</p></div></div>')
                    });
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    风采医生
    getgrpDoctor : function(grp_id){
        $.ajax({
            type : 'get',
            url : url+'doctor/getGrpDoctorList',
            dataType : 'jsonp',
            data : {grp_id:grp_id},
            success : function(res) {
                var data = res.data.grp_info;
                if(res.ret==0){
                    console.log(res.data);
                    $('.presence .bot .con .con-left').html('<div class="skilful" style="width: 100%;color: #333;font-size: 14px; padding-top: 10px; margin-left: 10px;">擅长领域: <p style="color:#666666;line-height: 25px; padding-right: 20px; margin-top: 5px;">'+ data.good_at+'</p></div><div class="experience" style="width: 100%;color: #333;font-size: 14px;padding-top: 4px;margin-left: 10px;margin-bottom: 10px;">执业经历: <p style="color:#666666;line-height: 25px;padding-right: 20px; margin-top: 5px;">'+ data.work_experience+'</p></div>')
                }else{
                    alert(res.msg);
                }
            }
        });
    },
    starDoctorList : function(grp_id,page_index,page_size){
        $.ajax({
            type : 'get',
            url : url+'doctor/starDoctorList',
            dataType : 'jsonp',
            data : {grp_id:grp_id,page_index:page_index},
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(res.data);
                    $.each(data,function(i,t){
                        $('#star-doctor-list').append('<div class="doctor-details" data-id="'+ t.id+'"><div class="top"><div class="left"><img src="'+ t.avatar_file+'"></div><div class="center"><div class="character"><p class="name">'+ t.doctor_name+'</p><p class="position">'+ t.job_name+'</p></div><div class="hospital"><p class="name">'+ t.hospital_name+'</p><p class="department">'+ t.department_name+'</p></div></div></div><div class="interaction"><div class="zan public"><img data-id="'+ t.id+'" src="images/icon17.png"><span>'+ t.like_count+'</span></div><div class="comment public"><img src="images/icon18.png"><span>'+ t.evaluate_count+'</span></div></div><div class="experience"><b>执业经历:</b>'+ t.desc+'</div></div>');
                    });
                }else{
                    alert(res.msg);
                }
            }
        });
    },
    //获取连接参数
    getQueryString : function(name){
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(decodeURI(r[2])); return null;
    },
//    获取科室列表
    getdepartment : function(hospital_id){
        $.ajax({
            type : 'get',
            url : url+'hospital/hospitalNewDepartment',
            dataType : 'jsonp',
            data : {hospital_id:hospital_id},
            success : function(res) {
                var data = res.data;
                childGetdepartment = [];
                if(res.ret==0){
                    console.log(res);
                    $('.appoint-dactor .header-tab .bot-con .department-list .left').append('<p>全部</p>');
                    $.each(data,function(i,t){
                        $('.appoint-dactor .header-tab .bot-con .department-list .left').append('<p>'+ t.name+'</p>');
                        childGetdepartment.push(t.child_department);
                    });
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    获取子科室
    child_getdepartment : function(index){
        $('.appoint-dactor .header-tab .bot-con .department-list .right').html('');
        $.each(childGetdepartment[index],function(i,t){
            $('.appoint-dactor .header-tab .bot-con .department-list .right').append('<p data-id="'+ t.id+'">'+ t.name+'</p>');
            console.log(t.name);
        });
    },
//    医生列表  doctor/doctorIndex
    doctor_list : function(page_index,page_size,citycode,hospital_id,department_id,doctor_id_arr){
        $.ajax({
            type : 'get',
            url : url+'doctor/doctorIndex',
            dataType : 'jsonp',
            data : {page_index:page_index,page_size:page_size,city_code:citycode,hospital_id:hospital_id,department_id:department_id,doctor_id_arr:doctor_id_arr},
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(res);
                    //if(page_index==1&&data==''){
                    //    consultationinterface.pagenull('很遗憾没有找到');
                    //}else{
                    //    $('.emptypage').remove();
                    //}
                    if(page_index==1){
                        if(data.length<page_size&&data.length!=0){
                            $('.infinite-scroll-preloader').html('<p style=" font-size: 14px; text-align: center;  color: #666; ">已加载全部</p>');
                        }else if(data==''){
                            consultationinterface.pagenull('很遗憾没有找到');
                            $('.infinite-scroll-preloader').hide();
                        }
                    }else{
                        if(data.length<page_size){
                            $('.infinite-scroll-preloader').html('<p style=" font-size: 14px; text-align: center;  color: #666; ">已加载全部</p>');
                        }
                    }
                    if(data!=''){
                        $('.emptypage').remove();
                    }
                    $.each(data,function(i,t){
                        $('.appoint-dactor .doctor-list').append('<li data-id="'+ t.doctor_id+'"><div class="left"><img src="'+ t.avatar_file+'"></div><div class="center"><div class="character"><p class="name">'+ t.user_name+'</p><p class="position">'+ t.job_name+'</p></div><div class="hospital"><p class="name">'+ t.hospital_name+'</p><p class="department">'+ t.department_name+'</p></div></div><div class="right"><img src="images/icon3.png"></div></li>');
                    });
                    if($.cookie('doctorid_l')!=0){
                        for(var i=0;i<$.cookie('doctorid_l');i++){
                            $('.appoint-dactor .doctor-list li').eq(i).addClass('icon').find('.right').find('img').attr('src','images/icon4.png');
                        }
                    }
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    会诊预下单
    pre_order : function(doctor_id_arr,uid){
        $.ajax({
            type : 'get',
            url : url+'index.php/diagnosis/consultationPresentation',
            dataType : 'jsonp',
            data : {uid:uid,doctor_id_arr:doctor_id_arr},
            success : function(res) {
                var data = res.data.doctor_info;
                var case_list = res.data.case_list;
                if(res.ret==0){
                    console.log(res);
                    $.each(data,function(i,t){
                        $('.groupconsultationh-datail .bot-form .doctor-list .win').append('<div class="doctor-infor"> <div class="head-pic" style="background: url('+ t.doctor_avatar_file+') center; background-size: cover;"></div><p class="name">'+ t.doctor_name+'</p><p class="hospital">'+ t.hospital_name+'</p></div>');
                        var $doctor_infor = $('.groupconsultationh-datail .bot-form .doctor-list .doctor-infor');
                        var $doctor_infor_l = $doctor_infor.length;
                        var $doctor_infor_w =  $doctor_infor.width();
                        $('.groupconsultationh-datail .bot-form .doctor-list .win').width($doctor_infor_l*$doctor_infor_w);
                    });
                    //$('.groupconsultationh-datail .bot-form .money .price').html(data.length*1500);
                    //$('.groupconsultationh-datail .payment-layer .con .money-num .p2').html(data.length*1500);
                    $.each(case_list,function(i,t){
                        $('.groupconsultationh-datail .medicalrecord-layer .con').append('<p class="public" data-id="'+ t.case_id+'">'+ t.case_name+'</p>')
                    });
                    $('.groupconsultationh-datail .medicalrecord-layer .con').append('<p class="build">新建病历</p>');
                    $('.groupconsultationh-datail .bot-form .money .price').html(res.data.group_info.total_amount);
                    $('.groupconsultationh-datail .bot-form .money p').html('(一位专家'+res.data.group_info.group_consultation_price+')')
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    空白页面
    pagenull : function(desc){
        $('body').append('<div class="emptypage" style="position: fixed;top:0;width:100%;height:100%;overflow: hidden;z-index: 5000;background: #F5F5F9;"><div class="con" style="width: 256px;height: auto;overflow: hidden;margin: auto;left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); position: absolute"><img style="width: 114px;height: auto;overflow: hidden;margin: auto;" src="images/icon27.png"><p style="font-size: 14px;text-align: center;color: #35424b;margin: 20px 0;">'+desc+'</p></div></div>')
        $('.emptypage .con button').live('click',function(){
            location.href=url
        });
        $('.emptypage').on('touchmove', function (event) {
            event.preventDefault();
        });
    },
//    空白页面
    pagenull2 : function(desc){
        $('body').append('<div class="emptypage" style="position: fixed;top:35%;width:100%;height:36%;overflow: hidden;z-index: 5000;background: #ebebeb;"><div class="con" style="width: 256px;height: auto;overflow: hidden;margin: auto;left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); position: absolute"><img style="width: 114px;height: auto;overflow: hidden;margin: auto;" src="images/icon27.png"><p style="font-size: 14px;text-align: center;color: #35424b;margin: 20px 0;">'+desc+'</p></div></div>')
        $('.emptypage .con button').live('click',function(){
            location.href=url
        });
        $('body').on('touchmove', function (event) {
            event.preventDefault();
        });
    },
//    创建病历医院列表
    hospital_list2 : function(city_code){
        $.ajax({
            type : 'get',
            url : url+'hospital/getAll',
            dataType : 'jsonp',
            data : {city_code:city_code,page_size:100},
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(res);
                    $.each(data,function(i,t){
                        $('.hospatil-layer .con').append('<p data-id="'+ t.id+'">'+ t.name+'</p>')
                    });

                }else{
                    alert(res.msg);
                }
            }
        });
    },
//    创建病历
    build_case : function(uid,treatment_type,hospital_id,disease_name,disease_desc){
        $.ajax({
            type : 'post',
            url : url+'diagnosis/caseData',
            dataType : 'json',
            data : {uid:uid,treatment_type:treatment_type,hospital_id:hospital_id,disease_name:disease_name,disease_desc:disease_desc},
            success : function(res) {
                if(res.ret==0){
                    console.log(res);
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//  订单列表
    order_list : function (uid,search_status,page_size,page_index){
        $.ajax({
            type : 'get',
            url : url+'diagnosis/orderList',
            dataType : 'jsonp',
            data : {uid:uid,search_status:search_status,page_size:page_size,page_index:page_index},
            success : function(res) {
                if(res.ret==0){
                    var data = res.data;
                    console.log(res);
                    if(page_index==1){
                        if(data.length<page_size&&data.length!=0){
                            $('.infinite-scroll-preloader').html('<p style=" font-size: 14px; text-align: center;  color: #666; ">已加载全部</p>');

                        }else if(data==''){
                            consultationinterface.pagenull2('还没有任何订单');
                            $('.infinite-scroll-preloader').hide();
                        }
                    }else{

                        if(data.length<page_size){
                            $('.infinite-scroll-preloader').html('<p style=" font-size: 14px; text-align: center;  color: #666; ">已加载全部</p>');
                        }
                    }
                    $.each(data,function(i,t){
                        var item = '';
                        $.each(t.doctor_list,function(e,o){
                           item+='<li><p class="name">'+ o.user_name+'</p><p class="position">'+ o.job_name+'</p><p class="hospital">'+ o.hospital_name+'</p></li>'
                        });
                        //搜索状态：1表示待付款；2待处理；4.待评价；不传输为全部订单;
                        if(search_status==1){
                            if(t.type!=9&&t.type!=10){
                                $('.order_stay .order-list').append('<div style="margin-top: 10px"><div class="order_num"><span>订单号：'+ t.order_no+'</span><img src="../img/mypage_img/icon_delete.png" alt="删除" data-id="'+t.order_id+'"></div><div style="position:relative;background-color:#fff;width: 100%;height: 74px;border-bottom: 1px solid #e6e6e6" data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" data-show_status="'+t.show_status+'" onclick="evaluation($(this))"><img id="hospital_pic" src="'+ t.pic+'" class="hospital_img"><img id="hospital_pic_hu" src="../img/icon_label.png" class="hospital_img" style="width:29px;height: 29px;z-index: 1;"><p style=" position: absolute; top:13px; left:13px; z-index: 2; font-size: 12px;color: #fff">'+ t.short_name+'</p><div id="hopital_name" class="message hospital_name">'+ t.hospital_name+'&nbsp;&nbsp;<span id="hospital_type">'+ t.type_text+'</span></div><div class="message hospital_subContent">科室：'+ t.department_name+'<span id="hospital_departments"></span></div><div class="message hospital_subContent" style="top: 48px;">类型：'+ t.diagnosis_type_name+'<span id="hospital_nurse"></span></div></div><div class="pay_detail" style="height: 65px"><button data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-show_status="'+t.show_status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" onclick="evaluation($(this))" value="立即付款" style="background-color: #e76a68">立即付款</button><span>未付款</span> </div></div>')
                            }else if(t.type==9){
                                $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul>'+item+'</ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ t.diagnosis_type_name+'</b></div><div class="div3 public">状态：<b>'+ t.status_text+'</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span><button data-id="'+ t.order_id+'" class=" ui-btn ui-shadow ui-corner-all">立即付款</button></div></div>')
                            }
                            else if(t.type==10){
                                $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">帮我推荐：</p><div class="divstay">正在与您取得联系</div></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">类型：<b>------</b></div><div class="div3 public">类型：<b>未付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span><button data-id="'+ t.order_id+'" class=" ui-btn ui-shadow ui-corner-all">立即付款</button></div></div>')
                            }
                        }else if(search_status==2){
                            if(t.type!=9&&t.type!=10){
                                $('.order_stay .order-list').append('<div style="margin-top: 10px"><div class="order_num"><span>订单号：'+ t.order_no+'</span><img src="../img/mypage_img/icon_delete.png" alt="删除" data-id="'+t.order_id+'"></div><div style="position:relative;background-color:#fff;width: 100%;height: 74px;border-bottom: 1px solid #e6e6e6" data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" data-show_status="'+t.show_status+'" onclick="evaluation($(this))"><img id="hospital_pic" src="'+ t.pic+'" class="hospital_img"><img id="hospital_pic_hu" src="../img/icon_label.png" class="hospital_img" style="width:29px;height: 29px;z-index: 1;"><p style=" position: absolute; top:13px; left:13px; z-index: 2; font-size: 12px;color: #fff">'+ t.short_name+'</p><div id="hopital_name" class="message hospital_name">'+ t.hospital_name+'&nbsp;&nbsp;<span id="hospital_type">'+ t.type_text+'</span></div><div class="message hospital_subContent">科室：'+ t.department_name+'<span id="hospital_departments"></span></div><div class="message hospital_subContent" style="top: 48px;">类型：'+ t.diagnosis_type_name+'<span id="hospital_nurse"></span></div></div><div class="pay_detail" style="height: 25px"><button style="width:auto; height:auto; right:0; top:2px; font-size:13px; letter-spacing:0;color: #808080;background: none">￥'+ t.total_amount+'</button><span>已付款</span> </div></div>')
                            }else if(t.type==9){
                                $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul>'+item+'</ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ t.diagnosis_type_name+'</b></div><div class="div3 public">状态：<b>'+ t.status_text+'</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span></div></div>')
                            }else if(t.type==10){
                                $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'"  class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">帮我推荐：</p><div class="divstay">正在与您取得联系</div></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">类型：<b>------</b></div><div class="div3 public">类型：<b>已付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span></div></div>')
                            }
                        }else if(search_status==4){
                            if(t.type!=9&&t.type!=10){
                                $('.order_stay .order-list').append('<div style="margin-top: 10px"><div class="order_num"><span>订单号：'+ t.order_no+'</span><img src="../img/mypage_img/icon_delete.png" alt="删除" data-id="'+t.order_id+'"></div><div style="position:relative;background-color:#fff;width: 100%;height: 74px;border-bottom: 1px solid #e6e6e6" data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" data-show_status="'+t.show_status+'" onclick="evaluation($(this))"><img id="hospital_pic" src="'+ t.pic+'" class="hospital_img"><img id="hospital_pic_hu" src="../img/icon_label.png" class="hospital_img" style="width:29px;height: 29px;z-index: 1;"><p style=" position: absolute; top:13px; left:13px; z-index: 2; font-size: 12px;color: #fff">'+ t.short_name+'</p><div id="hopital_name" class="message hospital_name">'+ t.hospital_name+'&nbsp;&nbsp;<span id="hospital_type">'+ t.type_text+'</span></div><div class="message hospital_subContent">科室：'+ t.department_name+'<span id="hospital_departments"></span></div><div class="message hospital_subContent" style="top: 48px;">类型：'+ t.diagnosis_type_name+'<span id="hospital_nurse"></span></div></div><div class="pay_detail" style="height: 49px"><button data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-show_status="'+t.show_status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" onclick="evaluation($(this))" value="立即付款" style="top:7px;background-color: #44b181">去评论</button><span style=" top:17px; font-size: 14px; ">金额：<a style="color: #ff8936;">￥'+t.total_amount+'</a></span> </div></div>');
                            }else if(t.type==9){
                                $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul>'+item+'</ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ t.diagnosis_type_name+'</b></div><div class="div3 public">状态：<b>'+ t.status_text+'</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span><button data-id="'+ t.order_id+'" style=" background: #44b181;" class="button2 ui-btn ui-shadow ui-corner-all">去评论</button></div></div>');
                            }else if(t.type==10){
                                $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul>'+item+'</ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ t.diagnosis_type_name+'</b></div><div class="div3 public">状态：<b>'+ t.status_text+'</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span><button data-id="'+ t.order_id+'" style=" background: #44b181;" class="button2 ui-btn ui-shadow ui-corner-all">去评论</button></div></div>');
                            }
                        }else if(search_status==''){
                            if(t.status==1){
                                if(t.type!=9&&t.type!=10){
                                    $('.order_stay .order-list').append('<div style="margin-top: 10px"><div class="order_num"><span>订单号：'+ t.order_no+'</span><img src="../img/mypage_img/icon_delete.png" alt="删除" data-id="'+t.order_id+'"></div><div style="position:relative;background-color:#fff;width: 100%;height: 74px;border-bottom: 1px solid #e6e6e6" data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" data-show_status="'+t.show_status+'" onclick="evaluation($(this))"><img id="hospital_pic" src="'+ t.pic+'" class="hospital_img"><img id="hospital_pic_hu" src="../img/icon_label.png" class="hospital_img" style="width:29px;height: 29px;z-index: 1;"><p style=" position: absolute; top:13px; left:13px; z-index: 2; font-size: 12px;color: #fff">'+ t.short_name+'</p><div id="hopital_name" class="message hospital_name">'+ t.hospital_name+'&nbsp;&nbsp;<span id="hospital_type">'+ t.type_text+'</span></div><div class="message hospital_subContent">科室：'+ t.department_name+'<span id="hospital_departments"></span></div><div class="message hospital_subContent" style="top: 48px;">类型：'+ t.diagnosis_type_name+'<span id="hospital_nurse"></span></div></div><div class="pay_detail" style="height: 65px"><button data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-show_status="'+t.show_status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" onclick="evaluation($(this))" value="立即付款" style="background-color: #e76a68">立即付款</button><span>未付款</span> </div></div>')
                                }else if(t.type==9){
                                    $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul>'+item+'</ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ t.diagnosis_type_name+'</b></div><div class="div3 public">状态：<b>'+ t.status_text+'</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span><button data-id="'+ t.order_id+'" class=" ui-btn ui-shadow ui-corner-all">立即付款</button></div></div>')
                                }else if(t.type==10){
                                    $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">帮我推荐：</p><div class="divstay">正在与您取得联系</div></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">类型：<b>------</b></div><div class="div3 public">类型：<b>未付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span><button data-id="'+ t.order_id+'" class=" ui-btn ui-shadow ui-corner-all">立即付款</button></div></div>')
                                }
                            }else if(t.status==3||t.status==2){
                                if(t.type!=9&&t.type!=10){
                                    $('.order_stay .order-list').append('<div style="margin-top: 10px"><div class="order_num"><span>订单号：'+ t.order_no+'</span><img src="../img/mypage_img/icon_delete.png" alt="删除" data-id="'+t.order_id+'"></div><div style="position:relative;background-color:#fff;width: 100%;height: 74px;border-bottom: 1px solid #e6e6e6" data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" data-show_status="'+t.show_status+'" onclick="evaluation($(this))"><img id="hospital_pic" src="'+ t.pic+'" class="hospital_img"><img id="hospital_pic_hu" src="../img/icon_label.png" class="hospital_img" style="width:29px;height: 29px;z-index: 1;"><p style=" position: absolute; top:13px; left:13px; z-index: 2; font-size: 12px;color: #fff">'+ t.short_name+'</p><div id="hopital_name" class="message hospital_name">'+ t.hospital_name+'&nbsp;&nbsp;<span id="hospital_type">'+ t.type_text+'</span></div><div class="message hospital_subContent">科室：'+ t.department_name+'<span id="hospital_departments"></span></div><div class="message hospital_subContent" style="top: 48px;">类型：'+ t.diagnosis_type_name+'<span id="hospital_nurse"></span></div></div><div class="pay_detail" style="height: 25px"><button style="width:auto; height:auto; right:0; top:2px; font-size:13px; letter-spacing:0;color: #808080;background: none">￥'+ t.total_amount+'</button><span>已付款</span> </div></div>')
                                }else if(t.type==9){
                                    $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul>'+item+'</ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ t.diagnosis_type_name+'</b></div><div class="div3 public">状态：<b>'+ t.status_text+'</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span></div></div>')
                                }else if(t.type==10){
                                    $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'"  class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">帮我推荐：</p><div class="divstay">正在与您取得联系</div></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">类型：<b>------</b></div><div class="div3 public">类型：<b>已付款</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span></div></div>')
                                }
                            }else if(t.status==4){
                                if(t.type!=9&&t.type!=10){
                                    $('.order_stay .order-list').append('<div style="margin-top: 10px"><div class="order_num"><span>订单号：'+ t.order_no+'</span><img src="../img/mypage_img/icon_delete.png" alt="删除" data-id="'+t.order_id+'"></div><div style="position:relative;background-color:#fff;width: 100%;height: 74px;border-bottom: 1px solid #e6e6e6" data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" data-show_status="'+t.show_status+'" onclick="evaluation($(this))"><img id="hospital_pic" src="'+ t.pic+'" class="hospital_img"><img id="hospital_pic_hu" src="../img/icon_label.png" class="hospital_img" style="width:29px;height: 29px;z-index: 1;"><p style=" position: absolute; top:13px; left:13px; z-index: 2; font-size: 12px;color: #fff">'+ t.short_name+'</p><div id="hopital_name" class="message hospital_name">'+ t.hospital_name+'&nbsp;&nbsp;<span id="hospital_type">'+ t.type_text+'</span></div><div class="message hospital_subContent">科室：'+ t.department_name+'<span id="hospital_departments"></span></div><div class="message hospital_subContent" style="top: 48px;">类型：'+ t.diagnosis_type_name+'<span id="hospital_nurse"></span></div></div><div class="pay_detail" style="height: 49px"><button data-doc="'+ t.doctor_id+'" data-id="'+t.order_id+'" data-index="'+t.status+'" data-show_status="'+t.show_status+'" data-content="对不起！您还没有成为钻石会员,暂时不能享受本次服务,立即充值999.00元成为钻石会员即可免费享受本次就医指导和转诊服务，并免费享受30天就医电话咨询，咨询热线：4006-30-50-60" onclick="evaluation($(this))" value="立即付款" style="top:7px;background-color: #44b181">去评论</button><span style=" top:17px; font-size: 14px; ">金额：<a style="color: #ff8936;">￥'+t.total_amount+'</a></span> </div></div>');
                                }else if(t.type==9){
                                    $('.order_stay .order-list').append('<div class="order-detail"><div class="order-num">订单编号：'+ t.order_no+'</div><div data-id="'+ t.order_id+'" class="expert"><img src="'+ t.pic+'"><div class="allexpert"><p class="tit">会诊专家：</p><ul>'+item+'</ul></div></div><div class="type"><div class="div1 public">类型：<b>会诊</b></div><div class="div2 public">科室：<b>'+ t.diagnosis_type_name+'</b></div><div class="div3 public">状态：<b>'+ t.status_text+'</b></div></div><div class="amount"><span>会诊金额：<b>￥'+ t.total_amount+'</b></span><button data-id="'+ t.order_id+'" style=" background: #44b181;" class="button2 ui-btn ui-shadow ui-corner-all">去评论</button></div></div>');
                                }
                            }
                        }
                        if(t.is_review==1){
                            $('.order_stay .order-list .order-detail .amount button').hide();
                        }
                    });
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//  banner
    banner : function(){
        $.ajax({
            type : 'get',
            url : url+'wish/index/groupConsultation',
            dataType : 'jsonp',
            data : {},
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(data)
                    $.each(data.focus_pic,function(i,t){
                        $('#full_feature .sw-slides').append('<li data-grp_id="'+ t.grp_id+'" data-type="'+ t.type+'" class="sw-slide"><img src="'+ t.pic_url+'" alt="Redhead girl"></li>');
                    });
                }else{
                    alert(res.msg);
                }
            }
        });
    },
//   提交评论
    sub_comment: function(data){
        $.ajax({
            type : 'post',
            url : url+'index.php/review/addReviewOrder',
            dataType : 'json',
            data : data,
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(data);
                    location.href= 'order_all.html'
                }else{
                    console.log(res.msg);
                }
            }
        });
    },
//    医生点赞
    doctorlike : function(uid,doctor_id,obj,text){
        $.ajax({
            type : 'get',
            url : url+'index.php/doctor/fav',
            dataType : 'jsonp',
            data : {uid:uid,doctor_id:doctor_id},
            success : function(res) {
                var data = res.data;
                if(res.ret==0){
                    console.log(data);
                    text++
                    obj.siblings('span').html(text);
                    obj.addClass('hover');
                }else{
                    console.log(res.msg);
                    if(res.msg=='error'){
                        alert('您已经点过赞了，看看别的医生吧！')
                    }
                }
            }
        });
    }
}
